<template>
    <div class="box6">
        <div class="title">
            <p>年度数据展示</p>
            <img src="../../images/dataScreen-title.png" alt="">
        </div>
        <div class="charts" ref=charts></div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
//引入echarts
import * as echarts from 'echarts';
let charts = ref();
//组件挂载完毕初始化图形图标
onMounted(() => {
    let mychart = echarts.init(charts.value);
    //设置配置项
    let option = {
        title: {
            text: '散点图',
            left: '40%',
            textStyle: {
                color: 'white'
            }
        },
        //x|y轴
        xAxis: {
            type: 'category',
            //两侧不留白
            boundaryGap: false,
            //分割线不要
            show: false

        },
        yAxis: {
            show: false,
        },
        grid: {
            left: 20,
            top: 0,
            right: 10,
            bottom: 20
        },
        series: {
            type: 'scatter',
            data: [33, 12, 45, 66, 55, 41, 54, 36, 29, 21, 12, 64, 21, 68, 25],
            // 散点图标记的形状
            // symbol: 'arrow',
            symbolSize: 16,
            //图文标签
            label: {
                show: true,
                position: 'top',
                color: 'red'
            },
            //散点图标记的颜色
            itemStyle: {
                color: {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'red' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'blue' // 100% 处的颜色
                    }],
                    global: false // 缺省为 false
                }
            }
        }
    };
    mychart.setOption(option);
});
</script>
<style scoped lang="scss">
.box6 {
    width: 100%;
    height: calc(100% - 40px);
    background: url(../../images/dataScreen-main-lb.png) no-repeat;
    background-size: 100% 100%;
    margin: 20px 0;

    .title {
        margin-left: 20px;
        color: white;
        font-size: 20px;
    }

    .charts {
        height: 260px;
    }
}
</style>